home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk Supreme
/
Softdisk Supreme.iso
/
pc
/
DSK Files
/
0-49
/
SD024b.dsk
/
NIM.bas
< prev
next >
Wrap
BASIC Source File
|
2003-06-12
|
7KB
|
212 lines
1 GOTO 10
2 CALL 768: RETURN
10 ZP = 49200
11 GOSUB 50010
20 DIM WP(14,3),FM(5,2),SW(3),PO(3),R3(3),R4(3)
25 DIM N$(2),TP(2)
30 GOSUB 9000: GOTO 4000
999 REM SQUARE DISAPPEAR ROUTINE
1000 FOR I = 9 TO 3 STEP -2
1010 X1 = X1 +1:Y1 = Y1 -1
1015 REM
1020 SCALE= I
1030 GOSUB 2: XDRAW 1 AT X2,Y2: GOSUB 2: XDRAW 2 AT X2,Y2
1040 SCALE= I -2
1050 GOSUB 2: XDRAW 1 AT X1,Y1: GOSUB 2: XDRAW 2 AT X1,Y1
1060 X2 = X1:Y2 = Y1
1070 NEXT
1080 GOSUB 2: XDRAW 2 AT X1,Y1
1099 REM FLASH SQUARE
1100 FOR J = 1 TO 5
1110 REM
1120 GOSUB 2: XDRAW 1 AT X1,Y1
1125 GOSUB 2: XDRAW 2 AT X1,Y1
1130 NEXT
1199 REM EXPAND AGAIN
1200 FOR I = 3 TO 9 STEP 2
1210 X1 = X1 -1:Y1 = Y1 +1
1215 REM
1220 SCALE= I -2
1230 GOSUB 2: XDRAW 2 AT X2,Y2
1240 SCALE= I
1250 GOSUB 2: XDRAW 2 AT X1,Y1
1260 X2 = X1:Y2 = Y1
1270 NEXT
1280 REM
1290 GOSUB 2: XDRAW 2 AT X1,Y1
1295 RETURN
1498 REM CALCULATE BASE POINT (X,Y)
1499 REM FOR RIGHTMOST SQUARE IN ROW R
1500 J = (R -1) *50:I = (PO(R) -1) *40
1505 X1 = I +15:Y1 = J +30
1510 X2 = I +15:Y2 = J +30
1598 REM PLOT THE CRUSHER, FULL SIZE,
1599 REM AT X1,Y1
1600 SCALE= 9: GOSUB 2: XDRAW 2 AT X1,Y1
1610 RETURN
2000 REM DECIDE IF IT IS THE FIRST MOVE
2010 IF MN >1 THEN GOTO 2030
2020 RN = INT( RND(1) *5) +1:R = FM(RN,1):RN = FM(RN,2): RETURN
2030 REM FIND GOOD MOVE
2040 FOR X = 1 TO WM
2050 FOR W = 1 TO 3:R3(W) = 0:R4(W) = 0: NEXT W
2060 FOR Y = 1 TO 3
2070 FOR Z = 1 TO 3
2080 IF R3(Z) >0 THEN GOTO 2120
2090 IF PO(Y) = WP(X,Z) THEN R3(Z) = Y:R4(Y) = Z: GOTO 2130
2120 NEXT Z
2130 NEXT Y
2132 C = 0:R5 = 6:R6 = 6
2134 FOR W = 1 TO 3
2135 R6 = R6 -R4(W)
2136 IF R3(W) >0 THEN C = C +1:R5 = R5 -R3(W): GOTO 2140
2140 NEXT W
2142 IF C = 2 THEN R = R5:RN = PO(R) -WP(X,R6): IF RN >0 THEN RETURN
2150 NEXT X
2160 R = INT( RND(1) *4)
2170 IF PO(R) = 0 THEN GOTO 2160
2180 RN = INT( RND(1) *PO(R)) +1: RETURN
4000 HOME : VTAB (7)
4010 PRINT "ENTER THE NUMBER OF PLAYERS (1 OR 2) ";: GET R$
4020 IF R$ = "1" GOTO 4100
4030 IF R$ = "2" GOTO 4200
4040 PRINT CHR$(7): GOTO 4000
4100 HOME : VTAB (7)
4110 PRINT "PLEASE ENTER YOUR NAME..."
4120 INPUT N$(1)
4130 HOME : VTAB (7)
4140 PRINT "DO YOU WANT TO GO FIRST? (Y FOR YES) ";: GET R$
4150 IF R$ < >"Y" GOTO 4180
4160 TP(1) = 1:TP(2) = 2:N$(2) = "THE COMPUTER"
4170 GOTO 4500
4180 TP(1) = 2:TP(2) = 1:N$(2) = N$(1):N$(1) = "THE COMPUTER"
4190 GOTO 4500
4200 TP(1) = 1:TP(2) = 1: HOME : VTAB (7)
4210 PRINT "PLEASE ENTER THE NAME"
4220 PRINT "OF THE PLAYER TO GO FIRST..."
4230 INPUT N$(1)
4240 HOME : VTAB (7)
4250 PRINT "PLEASE ENTER THE NAME"
4260 PRINT "OF THE PLAYER TO GO SECOND..."
4270 INPUT N$(2)
4500 GOSUB 9600
4505 P = 1:MN = 1
4510 HOME : VTAB (21)
4520 PRINT N$(P);"'S TURN..."
4525 ON TP(P) GOSUB 5100,5500
4530 IF (PO(1) = 0) AND (PO(2) = 0) AND (PO(3) = 0) THEN ON TP(P) GOTO 6500,6000
4540 P = P +1: IF P >2 THEN P = 1
4550 MN = MN +1: GOTO 4510
5100 Q1 = 0: PRINT ""
5110 PRINT "ENTER THE ROW OF YOUR CHOICE (1-3) ";
5115 GET R$
5120 IF R$ = "1" THEN R = 1: GOTO 5200
5130 IF R$ = "2" THEN R = 2: GOTO 5200
5140 IF R$ = "3" THEN R = 3: GOTO 5200
5150 PRINT CHR$(7);: REM BELL
5160 HTAB (36): VTAB (23): GOTO 5115
5199 REM <RETURN> OR <ESC>
5200 IF PO(R) = 0 GOTO 5150
5202 HOME : VTAB (21)
5210 PRINT "<RETURN> TO REMOVE THE INDICATED PIECE"
5220 PRINT "<ESC> TO END THE MOVE"
5225 GOSUB 1500
5230 GET R$
5240 IF R$ = CHR$(13) GOTO 5300: REM <RET>
5250 IF R$ = CHR$(27) GOTO 5400: REM <ESC>
5260 PRINT CHR$(7);: REM BELL
5270 HTAB (1): GOTO 5230
5299 REM <RETURN> - REMOVE THE SQUARE
5300 PO(R) = PO(R) -1
5305 Q1 = Q1 +1
5310 GOSUB 1000
5320 IF PO(R) < >0 THEN HTAB (1): GOTO 5225
5325 RETURN
5399 REM <ESC> - CHECK THAT SOME WERE TAKEN
5400 IF Q1 = 0 THEN HOME : VTAB (21): GOSUB 1600: GOTO 5100
5405 GOSUB 1600
5410 RETURN
5499 REM COMPUTER MOVE
5500 GOSUB 2000: REM GET R & RN
5501 FOR W = 1 TO 1000
5502 HOME : VTAB (21)
5504 PRINT "I CHOOSE TO TAKE ";RN;" FROM ROW ";R
5508 FOR W = 1 TO 600
5510 FOR IJ = 1 TO RN
5520 GOSUB 1500
5525 PO(R) = PO(R) -1: GOSUB 1000
5530 NEXT IJ
5547 REM
5550 RETURN
5560 GOTO 5500
5999 REM COMPUTER LOST
6000 HOME : VTAB (21)
6010 PRINT "SO I LOST...BIG DEAL!"
6020 INPUT "DO YOU DARE TRY AGAIN? (Y FOR YES) ";R$
6030 IF R$ = "Y" THEN TEXT : GOTO 4000
6040 GOTO 7000
6099 REM HUMAN LOST
6500 HOME : VTAB (21)
6510 IF (P = 1) AND (TP(2) = 2) GOTO 6600
6515 IF (P = 2) AND (TP(1) = 2) GOTO 6600
6520 P = P -1: IF P <1 THEN P = 2
6530 PRINT N$(P);" WON! WELL DONE!"
6540 GOTO 6610
6600 PRINT "I WON YET AGAIN!"
6610 INPUT "DO YOU WANT ANOTHER GAME? (Y FOR YES) ";R$
6620 IF R$ = "Y" THEN TEXT : GOTO 4000
6630 GOTO 7000
7000 TEXT : HOME : PRINT CHR$(4);"RUN MENU"
9000 TEXT : HOME
9010 HTAB (12): VTAB (7): PRINT "W E L C O M E"
9020 HTAB (17): VTAB (9): PRINT "T O"
9030 HTAB (16): VTAB (11): PRINT "N I M"
9040 VTAB (15): PRINT "BY: DAVID GRIEBELBAUER"
9050 HTAB (5): PRINT "DON SONOM"
9060 VTAB (23): PRINT "DO YOU WANT INSTRUCTIONS? (Y FOR YES) ";
9070 GET R$: IF R$ < >"Y" GOTO 9300
9080 HOME : HTAB (18): PRINT "N I M"
9090 PRINT "": PRINT "NIM IS A SIMPLE GAME FOR TWO PLAYERS;"
9100 PRINT "ONE OF WHICH MAY BE THE COMPUTER."
9110 PRINT "PLAYERS ALTERNATE REMOVING SQUARES FROM"
9120 PRINT "THE SCREEN. THE PLAYER WHO REMOVES THE"
9130 PRINT "LAST SQUARE LOSES."
9140 PRINT "": PRINT "ANY NUMBER OF SQUARES MAY BE REMOVED"
9150 PRINT "FROM A SINGLE ROW. ROW ONE IS AT THE"
9160 PRINT "TOP; ROW THREE IS AT THE BOTTOM."
9170 PRINT "": PRINT "ALL INPUT TO THE COMPUTER WILL BE"
9180 PRINT "SINGLE KEY-STROKE ENTRIES. USE THE"
9190 PRINT "<RETURN> KEY ONLY TO REMOVE A SQUARE"
9200 PRINT "FROM THE SCREEN."
9210 VTAB (23): PRINT "HIT THE <RETURN> KEY TO START THE GAME ";
9220 GET R$
9299 REM WINNING POSITIONS AND GOOD FIRST MOVES
9300 DATA 0,0,1,0,2,2,0,3,3,0,4,4,0,5,5,1,1,1,1,2,3,1,4,5,2,4,6
9305 DATA 1,2,1,1,3,3,3,1,2,1
9310 WM = 9
9320 FOR X = 1 TO WM
9330 FOR Y = 1 TO 3: READ WP(X,Y): NEXT
9340 NEXT
9350 FOR X = 1 TO 5
9360 FOR Y = 1 TO 2: READ FM(X,Y): NEXT
9370 NEXT
9499 REM ALL GRAPHICS INITIALIZATION
9500 DATA 19,2,0,6,0,9,0,44 , 62,0,58,4,32,37 ,53,181,62,62,4,0
9510 READ I
9520 FOR J = 16384 TO 16384 +I -1
9530 READ K: POKE J,K
9540 NEXT
9550 POKE 232,0: POKE 233,64: REM SHAPE TABLE IS AT THE TOP OF SCREEN #2
9560 RETURN
9599 REM SET UP SCREEN
9600 HGR : HCOLOR= 3: ROT= 0: SCALE= 9
9610 PO(1) = 3:PO(2) = 5:PO(3) = 7
9620 FOR R = 1 TO 3
9630 FOR K = 1 TO PO(R)
9640 J = (R -1) *50:I = (K -1) *40
9650 X1 = I +15:Y1 = J +30
9655 GOSUB 2: XDRAW 1 AT X1,Y1
9660 NEXT K
9670 NEXT R
9990 RETURN
50010 POKE 768,169: POKE 769,16: POKE 770,32: POKE 771,168: POKE 772,252: POKE 773,160: POKE 774,19: POKE 775,169: POKE 776,4: POKE 777,32: POKE 778,168: POKE 779,252: POKE 780,173: POKE 781,48: POKE 782,192: POKE 783,136: POKE 784,208: POKE 785,245: POKE 786,96: RETURN